# 指定基础镜像，这是分阶段构建的前期阶段
FROM 122.9.35.86:28082/stone/openjdk as builder
WORKDIR application
ARG APP_NAME
# 将编译构建得到的jar文件复制到镜像空间中
COPY ./target/${APP_NAME}  application.jar
# 通过工具spring-boot-jarmode-layertools从application.jar中提取拆分后的构建结果
RUN java -Djarmode=layertools -jar application.jar extract

# 正式构建镜像
FROM 122.9.35.86:28082/stone/openjdk
ENV RUN_TYPE=layer-jar
# 前一阶段从jar中提取除了多个文件，这里分别执行COPY命令复制到镜像空间中，每次COPY都是一个layer
COPY --from=builder /home/application/dependencies/ ${APP_HOME}
COPY --from=builder /home/application/spring-boot-loader/ ${APP_HOME}
COPY --from=builder /home/application/snapshot-dependencies/ ${APP_HOME}
COPY --from=builder /home/application/application/ ${APP_HOME}